package homework.exp03;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

public class D {
    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileReader(new File("D.in")));
        } catch (IOException e) {
            cin = new Scanner(System.in);
        }
    }

    private static int stepCount = 0; // 用于记录移动步数

    public static void main(String[] args) {
        int n = cin.nextInt();
        hanoi(n, 'a', 'b', 'c');
        System.out.println(stepCount);
        cin.close();
    }

    // 递归方法来解决汉诺塔问题
    private static void hanoi(int n, char from, char aux, char to) {
        if (n == 1) {
            move(n, from, to);
        } else {
            hanoi(n - 1, from, to, aux); // 将前n-1个圆盘从from移动到aux
            move(n, from, to); // 将第n个圆盘从from移动到to
            hanoi(n - 1, aux, from, to); // 将前n-1个圆盘从aux移动到to
        }
    }

    // 打印移动步骤并增加步数计数
    private static void move(int disk, char from, char to) {
        System.out.println("移动圆盘:" + disk + "从盘" + from + "到盘" + to);
        stepCount++;
    }
}